using System;
using System.Collections.Generic;
using System.Text;
using FrameworkX.ObjectSpace.Data.Schema;
using FrameworkX.ObjectSpace.Validation;

namespace FrameworkX.TinyCms.Core.Security
{
    [Serializable]
    public class User
    {
        private long _userid = 0;        
        [PrimaryKey]
        public long UserID
        {
            get { return _userid; }
            set { _userid = value; }
        }

        private string _login = string.Empty;      
        [String(20,false)]
        [NotEmpty]
        [UniqueFieldConstraint]
        public string Login
        {
            get { return _login; }
            set { _login = value; }
        }

        private string _password = string.Empty;
        [String(50, false)]
        [EncryptedStringProperty("ssssssdsdsdsdsds",false)]
        public string Password
        {
            get { return _password; }
            set { _password = value; }
        }

        
        private DateTime _lastLogin = new DateTime (1950,1,1);
        [DateTime(true)]
        public DateTime LastLogin
        {
            get { return _lastLogin; }
            set { _lastLogin = value; }
        }

        private string _email = string.Empty;
        [String(50, false)]
        [NotEmpty]
        public string Email
        {
            get { return _email; }
            set { _email = value; }
        }

        private string _firstName = string.Empty;

        [String(50, false)]
        [NotEmpty]
        public string FirstName
        {
            get { return _firstName; }
            set { _firstName = value; }
        }

        private string _lastName = string.Empty;
        [String(50, false)]
        public string LastName
        {
            get { return _lastName; }
            set { _lastName = value; }
        }

        private string _title = string.Empty;
        [String(20, false)]
        [NotEmpty]
        public string Title
        {
            get { return _title; }
            set { _title = value; }
        }


        private string _address = string.Empty;
        [String(50, false)]
        public string Address
        {
            get { return _address; }
            set { _address = value; }
        }

        private string _phone = string.Empty;
        [String(20, false)]
        public string Phone
        {
            get { return _phone; }
            set { _phone = value; }
        }

        private bool _enabled = true;
        [Boolean]
        public bool Enabled
        {
            get { return _enabled; }
            set { _enabled = value; }
        }

        private DateTime _lastPasswordChangeDate = DateTime.Now;
        [DateTime(true)]
        public DateTime LastPasswordChangeDate
        {
            get { return _lastPasswordChangeDate; }
            set { _lastPasswordChangeDate = value; }
        }


        public override string ToString()
        {
            return string.Format("{0} {1}", FirstName, LastName);
        }

    }

}
